Skip to content

gh-100227: Isolate the Import State to Each Interpreter#101941

Merged
ericsnowcurrently merged 3 commits intopython:mainfrom
ericsnowcurrently:isolate-import-state
Mar 9, 2023
Merged

gh-100227: Isolate the Import State to Each Interpreter#101941
ericsnowcurrently merged 3 commits intopython:mainfrom
ericsnowcurrently:isolate-import-state

Conversation

@ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Feb 15, 2023

Specific changes:

  • move the import lock to PyInterpreterState
  • move the "find_and_load" diagnostic state to PyInterpreterState

Note that the import lock exists to keep multiple imports of the same module in the same interpreter (but in different threads) from stomping on each other. Independently, we use a distinct global lock to protect globally shared import state, especially related to loaded extension modules. For now we can rely on the GIL as that lock but with a per-interpreter GIL we'll need a new global lock.

The remaining state in _PyRuntimeState.imports will continue being global.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants